﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevCore.Utility;

namespace DevFrameWork.Web.DevTest.DevDemo01
{
    public partial class 类型转换 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            bool isTrue = false;
            DateTime curDate = StringHelper.ObjectParse<DateTime>("2010-11-4", out isTrue);
            Response.Write(curDate.Date);

            //转换失败。设置为想要的默认值
            curDate = StringHelper.ObjectParse<DateTime>("2010-11a-4", DateTime.Now, out isTrue);
            Response.Write("是否转换成功:" + isTrue + ",当前的值为" + curDate.Date);


            int curI;
            curI = StringHelper.ObjectParse<int>("100a0", 10, out isTrue);
            Response.Write(curI);


            //判断是否是Decimal

            String IntStr = "123456";

            Decimal abc = 1234;

            StringHelper.ObjectParse<Decimal>(IntStr, abc, out isTrue);

           
            //判断是否是整型

           isTrue = StringHelper.ObjectIsT<int>("aa");
           Response.Write("是否是整型" + isTrue);

           isTrue = StringHelper.ObjectIsT<int>("12345678901111111111111111");
           Response.Write("是否是整型" + isTrue);


           isTrue = StringHelper.ObjectIsT<DateTime>("2010-11-02");
           Response.Write("是否是日期型" + isTrue);

    }
    }
}
